import Vue from 'vue'
import VueI18n from 'vue-i18n'
import Cookies from 'js-cookie'
import eleEnLocale from 'element-ui/lib/locale/lang/en'
import eleZhLocale from 'element-ui/lib/locale/lang/zh-CN'
import locale from 'element-ui/lib/locale' // lang i18n
import enLocale from './en'// {'英文'}
import zhLocale from './zh' // {'中文'}
Vue.use(VueI18n)
const messages = {
  en: { ...enLocale, ...eleEnLocale },
  zh: { ...zhLocale, ...eleZhLocale }
}
const i18n = new VueI18n({
  locale: Cookies.get('language') || 'zh',
  messages
})

locale.i18n((key, value) => i18n.t(key, value))

export default i18n
